<template>
  <a-modal
    :visible="visible"
    title="编辑"
    :width="500"
    :bodyStyle="{
      height: '500px',
      overflow: 'auto'
    }"
    okText="确定"
    @cancel="() => { $emit('cancel') }"
    @ok="confirm"
  >
    <!-- <detail-list :col="3">
      <detail-list-item :term="$t('key.xh')">{{ info.xht }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.name')">{{ info.xsxx.xm }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.sex')">{{ info.xsxx.xbmc }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.birthDate')">{{ info.xsxx.csrq }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.national')">{{ info.xsxx.mzmc }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.nj')">{{ info.xmsbnj }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.zy')">{{ info.xsxx.xjxx.sszymc }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.stuCate')">{{ info.xsxx.xjxx.pyccmc }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.politicalLandscape')">{{ info.xsxx.zzmmmc }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.xmsbnj')">{{ info.xmsbnj }}&nbsp;</detail-list-item>
      <detail-list-item :term="$t('key.xmsbmc')">{{ info.xmsbName }}&nbsp;</detail-list-item>
    </detail-list> -->

    <a-form :form="form">
      <a-col :span="24">
        <a-form-item
          label="项目名称"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16}"
        >
          <a-input disabled="true" v-model="projectName"/>
        </a-form-item>
      </a-col>
      <a-col :span="24">
        <a-form-item
          label="出发时间"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16}"
        >
          <a-date-picker  v-decorator="['cfsj',
          {
            rules: [{ required: true, message: '请选择出发日期' }],
          }]" placeholder="" />
        </a-form-item>
      </a-col>

      <a-col :span="24">
        <a-form-item
          label="出发地"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16}"
        >
          <a-input v-decorator="['cfd',
            {
              rules: [{ required: true, message: '请输入出发地!' }],
            }]" />
        </a-form-item>
      </a-col>
      <a-col :span="24">
        <a-form-item
          label="目的地"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16}"
        >
          <a-input v-decorator="['mdd',
            {
              rules: [{ required: true, message: '请输入目的地!' }],
            }]" />
        </a-form-item>
      </a-col>
      <a-col :span="24">
        <a-form-item
          label="项目名称"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16}"
          v-show="false"
        >
          <!-- <a-input disabled  v-model="info.gjhxmsb"/> -->
        <a-select  v-decorator="['gjhxmsbId',
          {
            rules: [{ required: true, message: ' ' }],
          }]" :allowClear="true" showSearch optionFilterProp="children">
              <a-select-option :key="i.id" :value="i.id" v-for="i in xmList">{{ i.projectName }}</a-select-option>
            </a-select>
        </a-form-item>
      </a-col>
    </a-form>
  </a-modal>

</template>

<script>
  import {STable} from '~'
  import DetailList from '~/tool/DetailList'
  import moment from 'moment'

  const DetailListItem = DetailList.Item

export default {
  props:['visible','info'],
  components: {DetailList, DetailListItem, STable},
  data () {
    return {
      form: this.$form.createForm(this),
     rptInfo: {
      //   yjjds: []
      },
      title:'',
      xmList:[],
      fileArr:[],
      tableData: [],
    }
  },
  watch:{
    info(){
      this.info.cfsj = moment(this.info.cfsj, 'YYYY-MM-DD')
      this.projectName = this.info.projectName
      this.$nextTick(()=>{
        let keys = Object.keys(this.form.getFieldsValue())
        let obj ={}
        keys.forEach(item =>{
          obj[item] = this.info[item]
        })
        console.log(obj,123123)
        this.form.setFieldsValue(obj)
      })

      // this.info.xsxx.csrq = moment(this.info.xsxx.csrq).format('YYYY-MM-DD')

    }
  },
  created(){
    // this.$api.student.reportBasic().then(res =>{
    //     if(res.data){
    //       this.xmList = res.data.xmsb
    //     }
    //   })
  },
  methods: {
    confirm () {
      var xh = this.$db.get('USER').xh
      this.form.validateFields((err, values) => {
        if (err) return
        // if (!this.tableData.length) {
        //   return this.$message.error('评审专家不能为空')
        // }
        values.cfsj = values.cfsj.format('YYYY-MM-DD')
        let params = Object.assign({
          // yxshyj: values.yxshzt === '09' ? '同意' : (values.yxshzt === '08' ? '不同意' : '建议修改或补充'),
          // id: this.info.id,
          isSubmit: true,
          xh:xh
        }, values)
        if(this.info.id)params.id = this.info.id
        this.$api.student.gjhxmsbAdd(params).then(res => {
          this.$message.success(res.msg)
          this.form.resetFields()
          this.$emit('cancel')
          this.$emit('refresh')
        })
      })
    }
  }
}
</script>

<style>

</style>
